<?php

$api = app('Dingo\Api\Routing\Router');
$moduleName = 'Product';

// 平台后台api
$api->version('v1', ['prefix' => 'admin-api', 'namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Admin\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'] ;

	// $api->resource('brands', "BrandController", ['only' => $allMethod]);
	$api->resource('shop/products', "ProductController", ['only' => $allMethod]);
	$api->resource('skus', "SkuController", ['only' => $allMethod]);

	$api->resource('carriage-templates', "CarriageTemplateController", ['only' => $allMethod]);
	
	$api->get('shop/getSupplyProductList', ['uses'=> "ProductController@getSupplyProductList"]);
    
	$api->get('/status-total/product', ['uses'=> "ProductController@statusTotal"]);

	$api->post('/skus/batch', ['uses'=> "SkuController@batch"]);

	// 商品批量更新
	$api->post('/product/batch-edit/total', ['uses' => "BatchEditController@totalStat"]);
	$api->post('/product/batch-edit', ['uses' => "BatchEditController@store"]);
});

// 租户api
// $api->version('v1', ['prefix' => 'tenant-api', 'namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Tenant\V1'], function ($api) {
// 	$allMethod = ['index', 'show', 'store', 'update', 'destroy'];
// });

// 普通用户api
$api->version('v1', ['prefix' => 'erp',  'namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Erp\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'];

	$api->resource('products', "ProductController", ['only' => $allMethod]);

	$api->post('/product/import', ['uses'=> "ProductBatchController@store"]);
});

// 普通用户api
$api->version('v1', ['namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Client\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'];

	$api->resource('shop/products', "ProductController", ['only' => ['index', 'show']]);
	$api->post('/shop/products/{uuid}', ['uses'=> "ProductController@show"]);

	$api->get('/shop/recommend-products', ['uses'=> "ProductController@recommendIndex"]);

	$api->get('/shop/recommend-cateogries', ['uses'=> "CategoryController@recommendIndex"]);
});